home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / File.Type.Notes / FTN.D8.0002 < prev    next >
Encoding:
Text File  |  1989-03-22  |  25.9 KB  |  494 lines  |  [04] ASCII Text (0x0000)

  1. Apple II
  2. File Type Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. File Type:         $D8 (216)
  6. Auxiliary Type:    $0002
  7.  
  8. Full Name:     Apple IIGS Sampled Instrument File
  9. Short Name:    ASIF File
  10.  
  11. Written by:    John Worthington & Matt Deatherage                March 1989
  12.  
  13. Files of this type and auxiliary type contain instruments in the Apple IIGS 
  14. Sampled Instrument Format (ASIF).
  15. _____________________________________________________________________________
  16.  
  17. The Apple IIGS Sampled Instrument Format (ASIF) is the standard format used 
  18. for storing Apple IIGS Sampled Instruments on disk.  All sampled instruments 
  19. supplied by Apple for the Apple IIGS Note Synthesizer will use this format.  
  20. Likewise, all utilities supporting Note Synthesizer sampled instruments will 
  21. also use this format.
  22.  
  23. ASIF is designed around the needs of the current Apple IIGS Note Synthesizer 
  24. and Apple IIGS sound hardware.  While the format of ASIF (especially INST 
  25. chunks) is greatly influenced by the Note Synthesizer, the information may be 
  26. sufficient for other sampled sound synthesizers to accurately render the 
  27. sound.
  28.  
  29. Most instrument files for the Apple IIGS have a ProDOS file type of $D6.  ASIF 
  30. files are instead identified as file type $D8, auxiliary type $0002 because of 
  31. their sampled nature.  All other instruments for the the Apple IIGS will be 
  32. identified by file type $D6.
  33.  
  34. Note:    Earlier ASIF documentation, not widely circulated, defined 
  35.          ASIF files as file type $CA, auxiliary type $8000.  As documented 
  36.          in this Note, ASIF has been reassigned to file type $D8 and 
  37.          auxiliary type $0002.  Applications which read files based on the 
  38.          old file type and auxiliary type should not perform adversely, 
  39.          since no other application should be creating files with that 
  40.          combination.  However, we strongly urge developers to create ASIF 
  41.          files with file type $D8 and auxiliary type $0002 only.  We 
  42.          further encourage developers to revise existing programs to use 
  43.          this new assignment at their earliest convenience.
  44.  
  45. ASIF files conform to the "EA IFF 85" Standard for Interchange Format Files 
  46. developed by Electronic Arts.  Electronic Arts additionally has some public 
  47. domain code available for reading and writing IFF files.
  48.  
  49. ASIF is provided more for compatibility than for interchange.  It is a highly 
  50. Apple IIGS specific file format.  Those wishing the highest level of sampled 
  51. sound compatibility across programs and CPUs should use Audio Interchange File 
  52. Format (Audio IFF).  Audio IFF is documented in Apple II File Type Note for 
  53. file type $D8, auxiliary type $0000.
  54.  
  55. This Note defines the required chunks INST and WAVE, as well as the optional 
  56. ("NAME"), copyright ("(c) "), author ("AUTH"), and annotation ("ANNO") chunks.  
  57. These are all "standard" chunks.  Additional chunks for private or future 
  58. needs may be added later.  Figure 1, located at the end of this Note, 
  59. illustrates the ASIF format in a box diagram.
  60.  
  61.  
  62. Required Data Chunks
  63.  
  64. An ASIF file consists of a single FORM ASIF, which contains one and only one 
  65. WAVE chunk and one or more INST chunks.  Each ASIF file defines at least one 
  66. instrument.
  67.  
  68. INST chunks contain all of the Note Synthesizer specific information needed to 
  69. define an instrument, exclusive of the actual wave form.  The information in 
  70. the INST chunk defines the characteristics of an instrument such as the 
  71. envelope, pitch range, and maximum pitch bend.  There must be at least one 
  72. INST chunk for each instrument in the ASIF file.
  73.  
  74. WAVE chunks contain the waveforms for a given instrument.  A WAVE chunk may 
  75. contain waveforms used by more than one instrument.  In most cases, the 
  76. waveforms used by an application will be merged into a single 64K block that 
  77. is loaded into DOC RAM when the application is launched.  In this case, there 
  78. would be several INST chunks referring to that single WAVE chunk.  Most music 
  79. applications will probably store instruments one to a file, which is the 
  80. preferred way of distributing ASIF instruments.
  81.  
  82. Note:    The length of any chunk must be even.  If a chunk has an odd 
  83.          length, a pad byte of $00 must be added to the end of the chunk.  
  84.          The pad byte, if present, should never have a value other than 
  85.          $00.
  86.  
  87.  
  88. The FORM Chunk
  89.  
  90. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  91.                        "FORM."
  92. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  93.                        cdID.  You may think of this value as the 
  94.                        offset to the end of the chunk.  Note that 
  95.                        this is a Reverse Long; the bytes are 
  96.                        stored high byte first.
  97. ckType    4 Types      The type of chunk.  These four bytes must be 
  98. (chunks...)            "ASIF."
  99.  
  100. Immediately following the 12-byte FORM chunk header are the data chunks of the 
  101. ASIF file.  There most be one and only one WAVE chunk, and at least one INST 
  102. chunk.  Optionally there may be name ("NAME"), copyright ("(c) "), author 
  103. ("AUTH"), or annotation ("ANNO") chunks.  All data chunks are part of the 
  104. larger FORM chunk, referred to as the FORM ASIF because of the ID and Type of 
  105. this chunk.
  106.  
  107.  
  108. The INST Chunk
  109.  
  110. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  111.                        "INST."
  112. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  113.                        cdID.  You may think of this value as the 
  114.                        offset to the end of the chunk.  Note that 
  115.                        this is a Reverse Long; the bytes are 
  116.                        stored high byte first.
  117. InstName  String       A Pascal String containing the name of the 
  118.                        instrument referred to by this INST block.  
  119.                        This string should be used as the display 
  120.                        name of the instrument.
  121.  
  122. Note:  The length byte of InstName is also referred to as INameLength.
  123.  
  124. SampleNum   Word       The number of the sample in the WAVE chunk to 
  125.                        which this instrument refers.
  126. Envelope    8 InstSegs Eight linear InstSegs defining the 
  127.                        instrument's envelope.
  128.  
  129. The InstSeg is a three-byte linear segment that describes a level and a 
  130. slope.  The level is called the breakpoint and represents the linear 
  131. amplitude of the sound.  The slope is described by an increment added or 
  132. subtracted from the current level at the update rate.  Regardless of the 
  133. increment, the breakpoint will never be exceeded.  All ASIF instruments 
  134. assume an update rate of 200 Hz.  The increment is a two-byte fixed 
  135. pointer; that is, the lower eight bits represent a fraction.  Thus when 
  136. the increment is one, it represents 1/256.  In this case, the increment 
  137. would have to be added 256 times (1.28 seconds) to cause the level to go 
  138. up by 1.  At a 200 Hz update rate each increment takes 5 milliseconds.  
  139. If an application wishes to use an update rate other than 200 Hz, the 
  140. envelope must be scaled as necessary.  If the envelope is not scaled, 
  141. the instrument will not sound correct.
  142.  
  143. The breakpoint is a byte between 0 and 127 ($00 and $7F).  It should 
  144. represent sound level in a logarithmic scale:  every 16 steps change the 
  145. amplitude by 6 dB.
  146.  
  147. Therefore the envelope is composed of eight InstSegs:
  148.  
  149. stage1    Byte       Breakpoint 1
  150.           2 Bytes    Increment 1
  151. stage2    Byte       Breakpoint 2
  152.           2 Bytes    Increment 2
  153. stage3    Byte       Breakpoint 3
  154.           2 Bytes    Increment 3
  155. stage4    Byte       Breakpoint 4
  156.           2 Bytes    Increment 4
  157. stage5    Byte       Breakpoint 5
  158.           2 Bytes    Increment 5
  159. stage6    Byte       Breakpoint 6
  160.           2 Bytes    Increment 6
  161. stage7    Byte       Breakpoint 7
  162.           2 Bytes    Increment 7
  163. stage8    Byte       Breakpoint 8
  164.           2 Bytes    Increment 8
  165.  
  166. Increment 1 is used to go from the initial level of 0 up to the level of 
  167. breakpoint 1.  Increment 2 is used to go from breakpoint 1 to breakpoint 
  168. 2, and so on.  The sustain level of the envelope, if there is one, is 
  169. created by setting the increment to zero, causing the envelope to get 
  170. stuck on that level.  The last segment used for release should always 
  171. have a breakpoint of zero, so the sound eventually reaches silence.  
  172. Unused segments should have a zero breakpoint and a non-zero increment.
  173.  
  174. ReleaseSegment     Byte      Specifies the release segment of the 
  175.                              envelope.  This must be a number from 1 to 
  176.                              7.  The release may take several segments 
  177.                              to get to zero.  The last segment should 
  178.                              always be zero.
  179. PriorityIncrement  Byte      A number that will be subtracted from the 
  180.                              generator priority when the envelope 
  181.                              reaches the sustain segment.  The sustain 
  182.                              segment is the first segment with a zero 
  183.                              increment.  When the release segment is 
  184.                              reached, the priority is cut in half.  The 
  185.                              priority of each generator is also 
  186.                              decremented by one each time a new 
  187.                              generator is allocated.  This causes older 
  188.                              notes to be preferred for stealing.
  189. PitchBendRange     Byte      The number of semitones that the pitch will 
  190.                              be raised when the pitchwheel reaches 127 
  191.                              (the center value is 64).  The legal 
  192.                              values for PitchBendRange are 1, 2, and 4.
  193. VibratoDepth       Byte      The initial fixed depth of vibrato, ranging 
  194.                              from 0 to 127.  Vibrato is a triangular-
  195.                              shaped Low Frequency Oscillator (LFO) 
  196.                              modulating the pitch of both oscillators 
  197.                              in a generator.  A VibratoDepth of zero 
  198.                              turns the vibrator mechanism off, which 
  199.                              saves some CPU time (since vibrato is 
  200.                              implemented in software).
  201. VibratoSpeed       Byte      Controls the rate of the vibrato LFO.  It can 
  202.                              be any byte value, although the range from 
  203.                              5 to 20 is most useful.  The frequency 
  204.                              range is linear, in 0.2 Hz steps.
  205. UpdateRate         Byte      Unused; set to zero.  Previous versions of ASIF 
  206.                              listed this byte as the update rate in .4 
  207.                              Hz, but a one-byte field is not large 
  208.                              enough to provide suitable resolution (102 
  209.                              Hz is the maximum allowed), much less the 
  210.                              standard Note Synthesizer value of 200 Hz 
  211.                              (the byte would have to hold the value 
  212.                              500; not an easy task for a byte).  All 
  213.                              ASIF instruments are assumed to have an 
  214.                              update rate of 200 Hz.
  215. AWaveCount         Byte      The number of waves in the following AWaveList.  
  216.                              There can be up to 255 waves in the 
  217.                              AWaveList.
  218. BWaveCount         Byte      The number of waves in the following BWaveList.  
  219.                              There can be up to 255 waves in the 
  220.                              BWaveList.
  221. AWaveList      AWaveCount    Waves.
  222. BWaveList      BWaveCount    Waves.
  223.  
  224. The WaveList structure is a variable-length array where each entry is 
  225. six bytes long.  The information is particular to the DOC, and the 
  226. developer should refer to the DOC information in the Apple IIGS Hardware 
  227. Reference and the Apple IIGS Toolbox Reference Update when creating 
  228. instruments.  Each six-byte entry represents a waveform and contains 
  229. information about the allowable pitch range of the waveform.  This means 
  230. that the waves can be "multi-sampled" across an imaginary keyboard.  
  231. When a note is played, WaveListA and WaveListB will be examined, and one 
  232. waveform will be picked and assigned to each oscillator.
  233.  
  234. Each wave in a WaveList has the following 6-byte format:
  235.  
  236. TopKey             Byte      The highest MIDI semitone this waveform will play.  
  237.                              The Note Synthesizer will examine the 
  238.                              TopKey field of each waveform until it 
  239.                              finds one greater than or equal to the 
  240.                              note it is trying to play.  The items in 
  241.                              the WaveList should be in order of 
  242.                              increasing TopKey values.  The last wave 
  243.                              should have a TopKey value of 127.  The 
  244.                              TopKey value is the split point between 
  245.                              the waveforms.
  246.  
  247. The next three bytes will be stuffed into the DOC registers:
  248.  
  249. WaveAddress        Byte      The high byte of the waveform address.  Note 
  250.                              that the value selected for WaveAddress 
  251.                              should assume that the waveform starts in 
  252.                              page zero.  When the waveform is actually 
  253.                              placed in DOC RAM, the values must be 
  254.                              adjusted as appropriate.  As an example, 
  255.                              for a waveform starting at $8000 in DOC 
  256.                              RAM, this value would be $80.
  257. WaveSize           Byte      Sets both the size of the wavetable and the 
  258.                              frequency resolution.
  259. DOCMode            Byte      Placed in the DOCs Mode register.  The interrupt-
  260.                              enable should always be zero.
  261.  
  262.                              Some ways this may be used are:
  263.                              Synthesizer ($00), where both oscillators 
  264.                              (A and B) run in free run mode
  265.                              Sample, no loop:  Oscillator A in swap 
  266.                              mode ($06) and oscillator B in one-shot 
  267.                              halted mode ($03).  Oscillator A will play 
  268.                              its wave once and start Oscillator B, 
  269.                              which will play its wave to the end once 
  270.                              and stop.
  271.                              Sampled with loop:  Oscillator A in swap 
  272.                              mode ($06), and Oscillator B in free-run 
  273.                              halted mode ($01).  Oscillator A will play 
  274.                              its wave once and then start Oscillator B, 
  275.                              which will play continuously until the 
  276.                              note ends.
  277.  
  278.                              The high nibble of the DOCMode is the channel
  279.                              number.  This must be set correctly for stereo
  280.                              output.  While all of the currently available
  281.                              stereo cards will map even-numbered channels to 
  282.                              the right and odd-numbered channels to the 
  283.                              left, software should use channel 0 for 
  284.                              right and channel 1 for left.  This will 
  285.                              ensure compatibility with cards that 
  286.                              provide more than two channels of output.  
  287.                              If you are not designing stereo 
  288.                              instruments, always set the channel to 
  289.                              zero.
  290. RelPitch           Word      Used to tune the waveform.  This will compensate 
  291.                              for different sample rates and waveform 
  292.                              sizes.  The high byte is in semitones, but 
  293.                              can be a signed number.  The low byte is 
  294.                              in 1/256 semitone increments.  Note that 
  295.                              the low byte is first in memory; this is a 
  296.                              regular 65816 Word.  A setting of zero is 
  297.                              the default for sounds that gave one cycle 
  298.                              per page of waveform memory.
  299.  
  300. The WaveList structure is designed to give greater flexibility in 
  301. creating realistic instrumental timbres.  It allows "multi-sampling" 
  302. with different samples of sounds on different ranges of pitch.  It 
  303. allows mixing of various sized wave forms, with different tuning on each 
  304. semitone, to allow separate tuning of each note.  This is one way to 
  305. duplicate special tuning systems like "just temperament."  The wave 
  306. pointers need not be different in this case, just the RelPitch fields.
  307.  
  308. Tuning is accurate to 1/128 of a semitone in the Note Synthesizer, 
  309. subject to the resolution setting of the DOC.  For accurate tuning on 
  310. lower notes, it may be necessary to use higher settings in the DOC 
  311. resolution register.
  312.  
  313. Note:    The Audio Interchange File Format (Audio IFF) also has a 
  314.          chunk named "INST" which will appear to a standard IFF reader the 
  315.          same as the ASIF "INST" chunk.  To tell the two apart, check the 
  316.          ckSize field.  The Audio IFF "INST" chunk will always have ckSize 
  317.          of 20 bytes, and the ASIF "INST" chunk will never have a chunk 
  318.          size of 20 bytes.
  319.  
  320.  
  321. The WAVE chunk
  322.  
  323. ckID          4 Bytes        The ID for this chunk.  These four bytes must be 
  324.                              "WAVE."
  325. ckSize        Rev. Long      The length of this chunk, excluding ckSize and 
  326.                              cdID.  You may think of this value as the 
  327.                              offset to the end of the chunk.  Note that 
  328.                              this is a Reverse Long; the bytes are 
  329.                              stored high byte first.
  330. WaveName      String         A Pascal String containing the name of the 
  331.                              waveform referred to by this WAVE block. 
  332.  
  333. Note:  The length byte of WaveName is also referred to as WaveNameLen.
  334.  
  335. WaveSize      Word           The size of the waveform WaveData, in bytes.  
  336.                              WaveSize may be any value from $0000 to 
  337.                              $FFFF.  This is a zero-based counter; 
  338.                              WaveData that is one byte long would 
  339.                              result in a WaveSize of $0000.  This 
  340.                              allows full 64K WaveData entries.
  341. NumSamples    Word           The number of different sounds in this WAVE 
  342.                              chunk.  NumSamples describes the number of 
  343.                              entries in SampleTable.  Note that this is 
  344.                              not necessarily the number of instruments.  
  345.                              Although not required, there should be a 
  346.                              WaveList entry in an INST chunk for each 
  347.                              entry in the SampleTable.
  348. SampleTable   NumSamples     Samples.
  349.  
  350. SampleTable is a table of the waveforms corresponding to different 
  351. "samples".  Each entry in SampleTable is 12 bytes long.  Each sample 
  352. entry is defined as follows:
  353.  
  354. Location      Word           The byte offset to the waveform from the beginning 
  355.                              of the WAVE chunk.
  356. Size          Word           The size of the waveform in 256-byte pages.  Size is 
  357.                              specified in pages since the sample size 
  358.                              passed to the DOC must be in pages.
  359. OrigFreq      Fixed          The original frequency that was sampled, in 
  360.                              hertz.  For example, if A440 was sampled, 
  361.                              the value of this field would be 440.00.  
  362.                              A value of zero in this field means that 
  363.                              the original frequency of the sample is 
  364.                              unknown.
  365. SampRate      Fixed          The sample rate used to generate this sample, in 
  366.                              hertz.  A value of zero in this field 
  367.                              means that the original sample rate is 
  368.                              unknown.
  369.  
  370. There are NumSamples of these sample entries in the SampleTable.
  371.  
  372. WaveData      WaveSize Bytes The actual waveform.  The DOC uses 
  373.                              samples in an eight-bit linear format.  A 
  374.                              value of $80 is considered to be a zero 
  375.                              crossing.  Positive values are greater 
  376.                              than $80; negative values are less than 
  377.                              $80.  Although WaveData may contain zeros 
  378.                              as oscillator control values, it should 
  379.                              never contain a zero value as a sample 
  380.                              value since this halts the oscillator.
  381.  
  382.  
  383. Optional Data Chunks
  384.  
  385. There are currently three types of optional data chunks.  These chunks may be 
  386. included in an ASIF file if desired.  They are considered part of the set of 
  387. "standard" chunks in the Electronic Arts "EA IFF 85" definition.
  388.  
  389.  
  390. The NAME Chunk
  391.  
  392. This chunk names the instrument of collection of instruments defined in the 
  393. ASIF file.  This chunk may be used to supply a display name for a collection 
  394. of instruments.  This can be useful since IFF programs know about the NAME 
  395. chunk, but may not know about the name field in INST or WAVE chunks.
  396.  
  397. ckID          4 Bytes        The ID for this chunk.  These four bytes must be 
  398.                              "NAME."
  399. ckSize        Rev. Long      The length of this chunk, excluding ckSize and 
  400.                              cdID.
  401. Name          Bytes          ASCII characters ($20-$7F) representing the name.  
  402.                              There should be ckSize characters.
  403.  
  404. The AUTH Chunk
  405.  
  406. ckID          4 Bytes        The ID for this chunk.  These four bytes must be 
  407.                              "AUTH."
  408. ckSize        Rev. Long      The length of this chunk, excluding ckSize and 
  409.                              cdID.
  410. author        Bytes          ASCII characters ($20-$7F) representing the name of 
  411.                              the author of the voices or collection of 
  412.                              voices.  There should be ckSize 
  413.                              characters.
  414.  
  415. The "(c) " Chunk
  416.  
  417. ckID          4 Bytes        The ID for this chunk.  These four bytes must be 
  418.                              "(c) ."
  419. ckSize        Rev. Long      The length of this chunk, excluding ckSize and 
  420.                              cdID.  You may think of this value as the 
  421.                              offset to the end of the chunk.
  422. notice        Bytes          ASCII characters ($20-$7F) representing a copyright 
  423.                              notice for the voice or collection of 
  424.                              voices.  There should be ckSize 
  425.                              characters.
  426.  
  427. The ANNO Chunk
  428.  
  429. ckID          4 Bytes        The ID for this chunk.  These four bytes must be 
  430.                              "ANNO."
  431. ckSize        Rev. Long      The length of this chunk, excluding ckSize and 
  432.                              cdID.  You may think of this value as the 
  433.                              offset to the end of the chunk.  Note that 
  434.                              this is a Reverse Long; the bytes are 
  435.                              stored high byte first.
  436. author        Bytes          ASCII characters ($20-$7F) representing the name of 
  437.                              the author of the voices or collection of 
  438.                              voices.  There should be ckSize 
  439.                              characters.
  440.  
  441.  
  442. Other Chunk Types
  443.  
  444. There are many types of IFF chunks other than those described in this 
  445. document.  New chunks may be added to ASIF files in the future.  If an 
  446. application encounters a chunk it doesn't recognize when reading an ASIF file, 
  447. it should ignore it.  Note that all chunks should be preserved when copying an 
  448. IFF file.
  449.  
  450. Figure 1 illustrates a sample ASIF file as a box diagram.
  451.  
  452.             --------------------------------------------
  453.             |        'FORM'            76112           |
  454.             |                                          |
  455.             |  --------------------------------------  |
  456.             |  |     'ASIF'                         |  |
  457.             |  |                                    |  |
  458.             |  |  --------------------------------  |  |
  459.             |  |  |  'NAME'            9         |  |  |
  460.             |  |  |  "Jazz Band"                 |  |  |
  461.             |  |  --------------------------------  |  |
  462.             |  |  --------------------------------  |  |
  463.             |  |  |  'INST'            50        |  |  |
  464.             |  |  |  3"Sax"0 ...                 |  |  |
  465.             |  |  --------------------------------  |  |
  466.             |  |  --------------------------------  |  |
  467.             |  |  |  'INST'            82        |  |  |
  468.             |  |  |  5"Drums"1 ...               |  |  |
  469.             |  |  --------------------------------  |  |
  470.             |  |  --------------------------------  |  |
  471.             |  |  |  'INST'            51        |  |  |
  472.             |  |  |  4"Bass"2 ...                |  |  |
  473.             |  |  --------------------------------  |  |
  474.             |  |  --------------------------------  |  |
  475.             |  |  |  'INST'            112       |  |  |
  476.             |  |  |  5"Piano"3 ...               |  |  |
  477.             |  |  --------------------------------  |  |
  478.             |  |  --------------------------------  |  |
  479.             |  |  |  'INST'            65656     |  |  |
  480.             |  |  |  10"Jazz Stuff" 65535 4 ...  |  |  |
  481.             |  |  --------------------------------  |  |
  482.             |  --------------------------------------  |
  483.             --------------------------------------------
  484.  
  485.                      Figure 1-Sample ASIF File
  486.  
  487.  
  488. Further Reference
  489. _____________________________________________________________________________
  490.     o    Apple IIGS Toolbox Reference Update
  491.     o    Advanced Sampler's Guide (Ensoniq Corporation)
  492.     o    "Programming the Ensoniq Mirage," Keyboard Magazine, November 1986
  493.     o    "EA IFF 85" Standard for Interchange Format Files, Electronic Arts, 
  494.          Inc.  Describes the underlying conventions for all IFF files.